import 'package:flutter/material.dart';
import 'package:flutter_chat_ui/pages/chat_room_page.dart';
import 'package:flutter_chat_ui/pages/onnx/onnx_chat_page.dart';
import 'package:flutter_chat_ui/routes/x_route.dart';
import 'package:flutter_chat_ui/utils/x_toast.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: const Size(375, 667),
      minTextAdapt: true,
      splitScreenMode: true,
      builder: (context, child) {
        return child!;
      },
      child: GetMaterialApp(
        title: 'Flutter Demo',
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
          colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
          useMaterial3: true,
        ),
        getPages: registerRoutes,
        builder: XToast.initToast(),
        home: const RootPage(),
      ),
    );
  }
}

class RootPage extends StatelessWidget {
  const RootPage({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Root Page')),
      body: Center(
        child: Column(
          spacing: 10,
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () => Get.to(() => const OnnxChatPage()),
              child: const Text('Go to ONNX Chat Page'),
            ),
            ElevatedButton(
              onPressed: () => Get.to(
                () => const ChatRoomPage(),
                popGesture: false,
              ),
              child: const Text('Go to Chat Room Page'),
            ),
          ],
        ),
      ),
    );
  }
}
